// windowProxy.ts

// 定义窗口类型，如果你项目中有 Electron 类型声明，可以改为 Electron.BrowserWindow
export interface WindowLike {
  webContents?: { send: (channel: string, ...args: any[]) => void }
  setResizable?: (resizable: boolean) => void
  setMinimumSize?: (width: number, height: number) => void
  setSize?: (width: number, height: number) => void
  close?: () => void
  [key: string]: any // 允许扩展
}

// 存放所有窗口实例
const windowManage: Record<string, WindowLike> = {}

const saveWindow = (id: string, window: WindowLike): void => {
  windowManage[id] = window
}

const getWindow = (id: string): WindowLike | undefined => {
  return windowManage[id]
}

const delWindow = (id: string): void => {
  delete windowManage[id]
}

const getWindowManage = (): Record<string, WindowLike> => {
  return windowManage
}

export { saveWindow, getWindow, delWindow, getWindowManage }
